package org.manon.json.meta;

import org.manon.json.annotation.JSonDiscriminatorType;


/**
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 */
public final class MetaPropertyDiscriminator extends MetaProperty {

	private JSonDiscriminatorType _type;
	private String _property;
	private String _value;
	
	public MetaPropertyDiscriminator(String name, String label, Class<?> clazz) {
		super(MetaPropertyType.DISCRIMINATOR,name, label, clazz);
	}

	/**
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(MetaProperty otherProperty) {
		return -10;
	}

	public void setType(JSonDiscriminatorType type) {
		_type = type;
	}

	public JSonDiscriminatorType getDiscriminatorType() {
		return _type;
	}

	public void setProperty(String property) {
		_property = property;
	}
	
	public String getProperty() {
		return _property;
	}

	public String getValue() {
		return _value;
	}

	public void setValue(String value) {
		_value = value;
	}

	@Override
	public String toString() {
		final StringBuilder builder = new StringBuilder(128);
		builder.append("Property Discriminator : ");
		toString(builder);
		builder.append(", type=[").append(_type).append("]");
		builder.append(", property=[").append(_property).append("]");
		builder.append(", value=[").append(_value).append("]");
		return builder.toString();
	}
	
	/**
	 * @see org.manon.json.meta.MetaProperty#accept(org.manon.json.meta.MetaPropertyVisitor)
	 */
	@Override
	public void accept(MetaPropertyVisitor visitor) {
		visitor.visit(this);
	}
	
}